export default class Stack {
  constructor() {
    this.arr = [];
  }
  push(ele) {
    this.arr.push(ele);
  }
  // 出栈
  pop() {
    // 删除并返回数组最后一个元素
    return this.arr.pop();
  }
  // 查看栈顶元素
  peek() {
    return this.arr[this.arr.length - 1];
  }
  //
  isEmpty() {
    return this.arr.length === 0;
  }
  size() {
    return this.arr.length;
  }
  toString() {
    var str = "";
    for (var i = 0; i < this.arr.length; i++) {
      str += this.arr[i] + " ";
    }
    return str;
  }
}
